<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>方法链式调用的实现</title>
</head>
<body>
    <script>
        var $ = aJquery = function(selector) {
            return new aJquery.fn.init(selector)
        }

        aJquery.fn = aJquery.prototype = {
            constructor: aJquery,
            init: function(selector) { // init 是一个构造函数，原型指向 aJquery 的原型
                this.selector = selector
                return this;  // 返回当前实例对象，即this，这样就可以实现链式调用
            }
        }

        aJquery.fn.init.prototype = aJquery.fn
    </script>
</body>
</html>